Skip to content

test(common-utils): cover mixed query operator generation - #3131

Open
Tyagiquamar wants to merge 3 commits into
ClickHouse:mainfrom
Tyagiquamar:fix/query-parser-mixed-operators-3032
Open

Tyagiquamar wants to merge 3 commits into
ClickHouse:mainfrom
Tyagiquamar:fix/query-parser-mixed-operators-3032

Conversation

@Tyagiquamar

@Tyagiquamar Tyagiquamar commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Adds baseline coverage for query generation before changing mixed-operator behavior, as requested in #3032. The PR now changes only tests, so existing saved searches and dashboards keep their current query generation.

Adds 16 cases to the existing SQL and English explanation table: mixed AND/OR chains, explicit grouping on either side, symbolic operators, implicit AND, infix NOT/AND NOT/OR NOT, leading NOT, and negated fields. Removes the previous grouping implementation and duplicate test harness. The behavior fix remains for a separate decision after this baseline is established.

Validated in Docker with Node 22.23.1 and Yarn 4.13.0:

  • Prettier check and changed-file ESLint passed.
  • yarn workspace @hyperdx/common-utils tsc --noEmit passed.
  • yarn workspace @hyperdx/common-utils build passed, including declaration generation.
  • yarn workspace @hyperdx/common-utils jest src/__tests__/queryParser.test.ts --ci --coverage=false --runInBand --silent --verbose=false passed all 421 tests.
  • yarn lint-staged passed for both staged files.

Related to #3032. This tests-only PR does not fix the underlying issue or require a release changeset.

@vercel

vercel Bot commented Sep 15, 2026

Copy link
Copy Markdown

@Tyagiquamar is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 35d85a1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@greptile-apps

greptile-apps Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Low risk] Adds test cases for query parser logic.

The PR is not safe to merge because mixed AND/OR searches can return rows outside the Lucene expression’s grouping.

Summary

The latest revision removes the mixed-operator grouping logic and replaces the earlier grouping assertions with tests expecting flat SQL.

  • This restores the search-result error the PR set out to fix.
  • The previous missing-changeset finding no longer applies because the current PR has no production-code change relative to the base.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Lucene: a AND (b OR c)"] --> B["Serialized: a AND b OR c"]
  B --> C["ClickHouse: (a AND b) OR c"]
  C --> D["A row matching only c is included"]
Loading

Reviews (2) · Last reviewed commit: "test(common-utils): cover mixed query op..."

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

1 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 1 P3

Already reported on an earlier push — no new comments. 1 unchanged from an earlier push (already inline above).


Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. This PR is tests-only (+97 lines to queryParser.test.ts); all 16 new {lucene, sql, english} assertions were verified to match the current serializer output, and no changeset is required (AGENTS.md item 7 exempts tests).

🟡 P2 — recommended

🔵 P3 nitpicks (1)
  • packages/common-utils/src/__tests__/queryParser.test.ts:182 — symbolic negation (!field) is the one operator form not pinned alongside the textual NOT and -field cases, so a regression in !-to-NOT serialization would slip past this baseline.
    • Fix: Add one case using symbolic negation (e.g. !ServiceName:"a" || ServiceName:"b") to pin its current serialization.

Reviewers (5): correctness, testing, maintainability, project-standards, previous-comments.

Testing gaps: The second testCases table (array/nested-field block, ~line 2712) has no mixed-operator cases; a grouping regression specific to array-field context would go uncaught — likely out of scope for this baseline but relevant to the eventual #3032 fix.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@brandon-pereira

Copy link
Copy Markdown
Member

@Tyagiquamar the review bot raised some valid comments to review. I also commented on the issue: #3032 (comment)

@Tyagiquamar Tyagiquamar changed the title fix(common-utils): preserve operator grouping for mixed AND/OR search queries test(common-utils): cover mixed query operator generation Oct 3, 2026
@Tyagiquamar

Copy link
Copy Markdown
Contributor Author

Updated in b19515c to the tests-only baseline you requested. The existing SQL/English table now covers 16 mixed-operator, explicit-parenthesis, symbolic, implicit, and negation cases. Query generation is unchanged from before this PR. Docker formatting, lint, type checking, package build, and all 421 query-parser tests pass.

@pulpdrew pulpdrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pulpdrew
pulpdrew requested a review from a team as a code owner November 21, 2026 11:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants